package core;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * describe:
 *
 * @author helloworldyu
 * @data 2018/3/26
 */
public class OwnerInvocationHandler implements InvocationHandler{
	IPerson person;

	public OwnerInvocationHandler(IPerson person) {
		this.person = person;
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		//===========如果是 设置自己的热度，要抛出异常=============
		if ( method.getName().equals("setHotOrNotRating")){
			throw new IllegalAccessException("没有权限更改自己的热度");
		}else if (method.getName().startsWith("get")||method.getName().startsWith("set")){
			return method.invoke(person,args);
		}else {
			return null;
		}
	}
}